<?php

declare(strict_types=1);

namespace App\CustHub\Controller;


use App\CustHub\Annotation\ApiAuth;
use App\CustHub\Annotation\VerifySignature;
use App\CustHub\Request\RoomInviteSchemeRequest;
use App\CustHub\Service\ChRoomInviteSchemeService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\PostMapping;
use Psr\Http\Message\ResponseInterface;

#[Controller('ch/room/invite/scheme'),ApiAuth,VerifySignature]
class RoomInviteSchemeController extends BaseController
{
    #[Inject]
    protected ChRoomInviteSchemeService $service;

    #[PostMapping('list')]
    public function list()
    {
        return $this->success($this->service->getSchemeList($this->request->all()));
    }

    #[PostMapping('selectList')]
    public function selectList()
    {
        return $this->success($this->service->getSelectList($this->request->all()));
    }

    /**
     * 新增方案
     * @param RoomInviteSchemeRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    #[PostMapping('save')]
    public function save(RoomInviteSchemeRequest $request)
    {
        return  $this->success(['id' => $this->service->save($request->all())]);
    }

    /**
     * 获取方案信息
     * @param RoomInviteSchemeRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    #[PostMapping('getInfo')]
    public function getInfo(RoomInviteSchemeRequest $request)
    {
        return $this->success($this->service->getInfo($request->all()));
    }

    /**
     * 修改方案
     * @param RoomInviteSchemeRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    #[PostMapping('update')]
    public function update(RoomInviteSchemeRequest $request)
    {
        return $this->service->update($this->request->input('id'),$request->all()) ? $this->success() : $this->error();
    }

    #[PostMapping('changeStatus')]
    public function changeStatus(RoomInviteSchemeRequest $request)
    {
        return $this->service->changeSchemeStatus($request->all()) ? $this->success() : $this->error();
    }

    /**
     * 删除方案
     * @param RoomInviteSchemeRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    #[PostMapping('delete')]
    public function delete(RoomInviteSchemeRequest $request)
    {
        return $this->service->delete([$request->input('id')]) ? $this->success() : $this->error();
    }

    /**
     * 获取生效群列表
     * @param RoomInviteSchemeRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     * * @throws \Psr\Container\ContainerExceptionInterface
     * * @throws \Psr\Container\NotFoundExceptionInterface
 */
    #[PostMapping('getActiveRooms')]
    public function getActiveRooms(RoomInviteSchemeRequest $request): ResponseInterface
    {
        return $this->success($this->service->getActiveRoomPageList($request->all()));
    }

    /**
     * 设置生效群进粉状态
     * @param RoomInviteSchemeRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     * * @throws \Psr\Container\ContainerExceptionInterface
     * * @throws \Psr\Container\NotFoundExceptionInterface
     */
    #[PostMapping('setActiveRoomStatus')]
    public function setActiveRoomStatus(RoomInviteSchemeRequest $request): ResponseInterface
    {
        return $this->service->setActiveRoomStatus($request->all()) ? $this->success() : $this->error();
    }

    /**
     * 获取固定成员群机器人列表
     * @param RoomInviteSchemeRequest $request
     * @return ResponseInterface
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    #[PostMapping('getRobotListByFixedMember')]
    public function getRobotListByFixedMember(RoomInviteSchemeRequest $request): ResponseInterface
    {
        return $this->success($this->service->getRobotListByFixedMember($request->all()));
    }
}